package org.TCP;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class GetMassage {
    public static void main(String[] args) throws IOException {
        //创建一个Socket对象
        ServerSocket ss = new ServerSocket(10086);
        //监听客户端连接
        Socket socket = ss.accept();


        //获取输入流
        InputStream is = socket.getInputStream();
        //将字节流转换为字符流 读中文
        InputStreamReader isr = new InputStreamReader(is);
        //使用缓冲区读取数据 提高效率
        BufferedReader br = new BufferedReader(isr);


        //读取数据
        String line;
        while ((line = br.readLine())!=null) {
            System.out.println(line);
        }
        //关闭Socket
        socket.close();
        //关闭ServerSocket
        ss.close();

    }
}
